package com.nuc.bigdata.app.service.impl;

import com.nuc.bigdata.app.service.UserService;
import com.nuc.bigdata.domain.entity.User;
import com.nuc.bigdata.feign.UserServiceFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author JackLuo
 * @date 2019/10/30
 */
@Service
public class UserServiceImpl implements UserService {
    private final UserServiceFeign serviceFeign;

    @Autowired
    public UserServiceImpl(UserServiceFeign serviceFeign){
        this.serviceFeign = serviceFeign;
    }

    /**
     * 注册用户
     * @param user 前端用户数据
     * @return 用户
     */
    @Override
    @Transactional(rollbackForClassName = "Exception")
    public User signUp(User user) throws Exception {
        return serviceFeign.signUp(user);
    }

    /**
     * 登录用户
     * @param user 用户名和密码
     * @return 用户
     */
    @Override
    @Transactional(rollbackForClassName = "Exception")
    public User toLogin(User user) throws Exception {
        return serviceFeign.toLogin(user.getLoginName(),user.getPassword() );
    }
}
